#ifndef BINARY_HEAP_H
#define BINARY_HEAP_H

#include "plat.h"
#include "elnet.h"

#ifdef __cplusplus
extern "C" {
#endif

#define USE_BINARY_HEAP_STATIC 0

typedef struct binary_heap_st
{
    uint16_t usItemSize;
    uint16_t usItemMax;
    uint16_t usItemCnt;
    int (*pfCompare)(void *, void *);
    uint8_t  pbPool[];
}bhp_t;

extern int binary_heap_init(bhp_t *, uint16_t, uint16_t, int (*)(void *, void *));
#if USE_BINARY_HEAP_STATIC == 0
extern bhp_t * binary_heap_create(uint16_t, uint16_t, int (*)(void *, void *));
extern void binary_heap_destroy(bhp_t *);
#endif
extern int binary_heap_insert(bhp_t *, void *, uint16_t);
extern int binary_heap_fetch(bhp_t *, void *, uint16_t);
#ifdef __cplusplus
}
#endif
#endif